﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevenBlog.Core.Data;
using LevenBlog.Core.Entities;
using LevenBlog.Core.Utils;

namespace LevenBlog.Core.Service
{
    public static class Log
    {
        public static int Count(IDbProvider provider)
        {
            return ProviderManager.Factory.Log.Count(provider);
        }

        public static lb_log Get(IDbProvider provider, int id)
        {
            return ProviderManager.Factory.Log.Get(provider, id);
        }

        public static IList<lb_log> Get(IDbProvider provider, int pageSize, int currentPage)
        {
            return ProviderManager.Factory.Log.Get(provider, pageSize, currentPage);
        }

        public static void Write(IDbProvider provider, lb_log log)
        {
            ProviderManager.Factory.Log.Insert(provider, log);
        }

        public static void Delete(IDbProvider provider, int id)
        {
            ProviderManager.Factory.Log.Delete(provider, id);
        }

        public static void Delete(IDbProvider provider, DateTime startTime, DateTime endTime)
        {
            ProviderManager.Factory.Log.DeleteFromDateTime(provider, startTime, endTime);
        }

        /// <summary>
        /// 删除全部日志(最近一周的不能删除)
        /// </summary>
        /// <param name="provider"></param>
        public static void DeleteAll(IDbProvider provider)
        {
            DateTime endTime = DateTime.Now.AddDays(-7.0);
            ProviderManager.Factory.Log.DeleteFromDateTime(provider, endTime);
        }
    }
}
